define([ "app", "jquery", "md5", "ecb","artDialog","iframeTools",  "services/UserService","services/TipsService",
		"directives/AudioPlayer",
		"resources/UserResource", "resources/ShareResource" ],
		function(app) {
			var deps = [ "$scope", "$state","$sce", "$timeout", "$window", "$location", "$stateParams","TipsService", "UserService", "UserResource", "ShareResource" ];

			function controller($scope, $state,$sce,$timeout, $window, $location, $stateParams,TipsService, UserService, UserResource, ShareResource) {
				$scope.shareId = $stateParams.shareId;
				initDate();
				
				function initDate(){
					// 初始化分享内容
					ShareResource.shareDetail($scope.shareId).success(function(data){
						$scope.shareVo=data.obj;
						
						if($scope.shareVo.shareType=='4' || $scope.shareVo.shareType=='1'){
							$scope.shareVo.shareUrl[0] = $sce.trustAsResourceUrl('http://p2zmea1zp.bkt.clouddn.com/'+$scope.shareVo.shareUrl[0]);//第二种处理方式	
						}
									
		            });
				}
				
				$scope.shield = function() {
					ShareResource.shield($scope.shareId,1).success(function(data){
						if (data.resCode=='0000') {
							TipsService.show("屏蔽帖子成功!");
							$state.go("home.shareManagement");
						}
		            });
				};
				
				$scope.releaseShield = function() {
					ShareResource.shield($scope.shareId,0).success(function(data){
						if (data.resCode=='0000') {
							TipsService.show("解封帖子成功!");
							$state.go("home.shareManagement");
						}
		            });
				};
				
				$scope.edit = function() {
					$scope.shareVo.shareId=$scope.shareId;
					ShareResource.edit($scope.shareVo).success(function(data){
						if (data.resCode=='0000') {
							TipsService.show("修改帖子成功!");
							$state.go("home.shareManagement");
						}
		            });
				};
				

				/*$scope.close = function($scope,ShareResource) {
					$modalInstance.close();
				};*/
				
				$scope.close = function($scope,ShareResource) {
					$state.go("home.shareManagement");
				};
			}
			controller.$inject = deps;
			return app.lazy.controller("EditShareController", controller);
		});
